#include <string.h>
#include <osso-ic.h>
#include "icd_log.h"
#include "policy_api.h"

void policy_one_connected(struct icd_policy_request *network,GSList *existing_connections,gpointer *private)
{
	icd_policy_nw_close_fn nw_close = *(icd_policy_nw_close_fn *)private;
	struct icd_policy_request *conndata;
	ILOG_INFO("policy one got connected notification");
	if (existing_connections)
	{
		GSList *connection = existing_connections;
		while (1)
		{
			GSList *conn = connection->next;
			conndata = connection->data;
			if (connection->data != network)
			{
				ILOG_INFO("policy one disconnecting connection %p",conndata);
				nw_close(conndata);
			}
			else
			{
				ILOG_INFO("policy one found the same connection");
			}
			connection = conn;
			if (!conn)
			{
				return;
			}
		}
	}
	
}

void icd_policy_init(struct icd_policy_api *policy_api,icd_policy_nw_add_fn add_network,icd_policy_request_merge_fn merge_requests,icd_policy_request_make_new_fn make_request,icd_policy_scan_start_fn scan_start,icd_policy_scan_stop_fn scan_stop,icd_policy_nw_close_fn nw_close,icd_policy_network_priority_fn priority,icd_policy_service_module_check_fn srv_check)
{
	policy_api->connected = policy_one_connected;
	policy_api->private = nw_close;
}
